package web_1;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class servletDemo implements Servlet {
   public servletDemo(){
        System.out.println("构造方法");
    }
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        System.out.println("初始化");
    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
       HttpServletRequest httpreq= (HttpServletRequest)servletRequest;
      String str =  httpreq.getMethod();

        System.out.println(str);
        if("POST".equals(str)){
            System.out.println("POST方式提交");
        }else {
            System.out.println("GET方式提交");
        }
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        System.out.println("销毁");
    }
}